using System.Collections.Generic;

namespace Framework
{
    /// <summary>
    /// Stores variables for logging, used by In/Out logging methods.
    /// </summary>
    public class LogVariable
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LogVariable"/> class.
        /// </summary>
        private LogVariable()
        {
            Variables = new List<KeyValuePair<string, object>>();
        }

        /// <summary>
        /// Gets or sets the variable list for logging.
        /// </summary>
        /// <value>The variables.</value>
        public IList<KeyValuePair<string, object>> Variables { get; set; }

        /// <summary>
        /// Adds the specified variable name & value to the variables list. You can add new variables through chaining.
        /// </summary>
        /// <param name="variableName">Name of the variable.</param>
        /// <param name="variableValue">The variable value.</param>
        /// <returns></returns>
        public LogVariable Add(string variableName, object variableValue)
        {
            Variables.Add(new KeyValuePair<string, object>(variableName, variableValue));

            return this;
        }

        /// <summary>
        /// Creates a new LogVariable chain, You can add new variables through chaining via the Add method.
        /// </summary>
        /// <param name="variableName">Name of the variable.</param>
        /// <param name="variableValue">The variable value.</param>
        /// <returns></returns>
        public static LogVariable New(string variableName, object variableValue)
        {
            var result = new LogVariable();

            return result.Add(variableName, variableValue);
        }

        /// <summary>
        /// Creates a new LogVariable chain, You can add new variables through chaining via the Add method.
        /// </summary>
        /// <returns></returns>
        public static LogVariable New()
        {
            return new LogVariable();
        }
    }
}